let n1 = 123123412341234;
//toLocaleString()方法
function fn(num) {
    return Number(num + "").toLocaleString();
}
console.log("toLocaleString", fn(n1));

//正则匹配
const toNum = (number) => {
    return (number + "").replace(/(\d)(?=(\d{3})+$)/g, '$1,');
}
console.log("正则", toNum(n1));